﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Batman.Jianbei.Forum.Migrations.JianbeiForumDbContext2Migrations
{
    public partial class _201903191 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "InsulinPumpModel",
                columns: table => new
                {
                    Id = table.Column<string>(nullable: false),
                    Name = table.Column<string>(maxLength: 50, nullable: false),
                    InsulinPumpId = table.Column<string>(maxLength: 36, nullable: false),
                    Sort = table.Column<int>(nullable: false),
                    CreateBy = table.Column<string>(maxLength: 36, nullable: false),
                    CreateAt = table.Column<DateTime>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_InsulinPumpModel", x => x.Id);
                    table.ForeignKey(
                        name: "FK_InsulinPumpModel_InsulinPump_InsulinPumpId",
                        column: x => x.InsulinPumpId,
                        principalTable: "InsulinPump",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "PumpSaleInfomation",
                columns: table => new
                {
                    Id = table.Column<string>(nullable: false),
                    PumpNo = table.Column<string>(maxLength: 35, nullable: false),
                    Phone = table.Column<string>(maxLength: 20, nullable: false),
                    ModeId = table.Column<string>(maxLength: 36, nullable: false),
                    InsulinPumpModelId = table.Column<string>(nullable: false),
                    PurchaseAt = table.Column<DateTime>(nullable: false),
                    WarrantyStart = table.Column<DateTime>(nullable: false),
                    WarrantyEnd = table.Column<DateTime>(nullable: false),
                    CreateBy = table.Column<string>(maxLength: 36, nullable: false),
                    CreateAt = table.Column<DateTime>(nullable: false),
                    Remark = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PumpSaleInfomation", x => x.Id);
                    table.ForeignKey(
                        name: "FK_PumpSaleInfomation_InsulinPumpModel_InsulinPumpModelId",
                        column: x => x.InsulinPumpModelId,
                        principalTable: "InsulinPumpModel",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_InsulinPumpModel_InsulinPumpId",
                table: "InsulinPumpModel",
                column: "InsulinPumpId");

            migrationBuilder.CreateIndex(
                name: "IX_PumpSaleInfomation_InsulinPumpModelId",
                table: "PumpSaleInfomation",
                column: "InsulinPumpModelId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "PumpSaleInfomation");

            migrationBuilder.DropTable(
                name: "InsulinPumpModel");
        }
    }
}
